from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.decorators import login_required

from meiduo.apps.users import views


urlpatterns = [
    url(r'^register/$', views.UserRegisterView.as_view()),

    # 判断用户名重复注册
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.CheckUsernameView.as_view()),

    # 判断手机号重复注册
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.CheckPhoneView.as_view()),

    # 用户登录
    url(r'^login/$', views.UserLoginView.as_view()),

    # 用户退出
    url(r'^logout/$', views.UserLogoutView.as_view()),

    # 用户中心
    url(r'^info/$', views.UserCenterInfoView.as_view()),
    # 登录状态
    # url(r'^info/$', login_required(views.UserCenterInfoView.as_view())),

    # 邮件发送
    url(r'^emails/$', views.EmailView.as_view()),
    url(r'^emails/verification/$', views.EmailView.as_view()),

    # 收货地址
    url(r'^addresses/$', views.UserAddressView.as_view()),

    # 新增地址
    url(r'^addresses/create/$', views.UserAddressCreateView.as_view()),

    # 修改地址
    url(r'^addresses/(?P<address_id>\d+)/$', views.UserAddressUpdateView.as_view()),

    # 设置默认地址
    url(r'^addresses/(?P<address_id>\d+)/default/$', views.UserAddressDefaultView.as_view()),

    # 修改地址标题
    url(r'^addresses/(?P<address_id>\d+)/title/$', views.UserAddressTitleView.as_view()),

    # 密码修改页面
    url(r'^password/$', views.UserRepasswordView.as_view()),

]
